package phase03.module04.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import phase03.module04.dao.HelloDao;

import java.util.List;
import java.util.Map;

/**
 * @author Alex Zhang
 */
@RestController
public class HelloController {

    private HelloDao dao = new HelloDao();

    @GetMapping(value = "hello")
    public String helle() {
        return "hello SpringBoot";
    }

    @PostMapping(value = "user")
    public void add(String username, String password, String email) {
        dao.createUser(username, password, email);
    }

    @GetMapping(value = "user")
    public List<Map<String, Object>> get() {
        return dao.getUsers();
    }
}
